package com.la100.common.dao.core;

import java.util.ArrayList;
import java.util.List;

/**
 * find请求的封装类
 * 
 * @author lishi
 * @date 2017-11-29 上午11:56:45
 */
public class FindRequestEntity {
	private List<WhereEntity> whereList = new ArrayList<WhereEntity>();
	private List<OrderEntity> orderList = new ArrayList<OrderEntity>();
	private Integer pageNo;
	private Integer pageSize;
	
	public FindRequestEntity addWhere(String property,WhereEnum whereEnum,Object value)throws Exception{
		WhereEntity whereEntity = new WhereEntity(property,whereEnum,value);
		if(whereList == null) {
			whereList = new ArrayList<WhereEntity>();
		}
		whereList.add(whereEntity);
		return this;
	}
	
	public FindRequestEntity addOrder(String property,OrderEnum order)throws Exception{
		OrderEntity orderEntity = new OrderEntity(property,order);
		if(orderList == null) {
			orderList = new ArrayList<OrderEntity>();
		}
		orderList.add(orderEntity);
		return this;
	}

	public void setPage(Integer pageNo,Integer pageSize) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
	}

	public List<WhereEntity> getWhereList() {
		return whereList;
	}

	public List<OrderEntity> getOrderList() {
		return orderList;
	}

	public Integer getPageNo() {
		return pageNo;
	}
	
	
	public Integer getStartNo() {
		return (pageNo - 1) * pageSize ;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	
	public FindRequestEntity getParam(){
		return this;
	}
}
